#encoding=utf-8
import redis

def main():
    client = redis.Redis(host='39.98.165.236',port=6379,
                         password='1qaz2wsx')
    print(client)
    client.set('username','hellokitty',ex=300)
    print(client.ttl('username'))
    print(client.get('username'))  #输出字节串，可能是二进制数
    print(client.get('username').decode())  #将上面的字节串解码以后，就是字符串了
    client.set('nickname','付少蕾')
    print(client.get('nickname'))
    print(client.get('nickname').decode())
    client.set('yuting','300')
    client.incr('yuting')
    client.incrby('yuting',50)
    print(client.get('yuting'))
    print(client.get('yuting').decode())
    # print(client.get('yuting'))
    client.hset('stu1','id','1001')
    client.hset('stu1','name','王大锤')
    print(client.hgetall('stu1'))
    print(client.hget('stu1','name').decode())
    client.rpush('list1',10,20,30,40)
    print(client.lrange('list1',0,-1))

if __name__ == '__main__':
    main()